﻿using System;
using RootfusHostView;

namespace RootfusCoreComponents
{
    /// <summary>
    /// This is the callback object that is used by the addin. We are basically a shim that forwards the call
    /// back to the wrapper object which manages all state.
    /// </summary>
    class AddinCallback : SICallback
    {
        RootfusSurfaceItemWrapper _parent;

        /// <summary>
        /// Create the callback, along with the guy we will forward everything to!
        /// </summary>
        /// <param name="parent"></param>
        public AddinCallback(RootfusSurfaceItemWrapper parent)
        {
            _parent = parent;
        }

        /// <summary>
        /// The addin has changed its internal config -- we need to keep this so we can "save" it when it is time.
        /// </summary>
        /// <param name="xmltext"></param>
        public override void UpdateSaveInformation(string xmltext)
        {
            _parent.UpdateSaveInformation(xmltext);
        }

        /// <summary>
        /// Get the ROOT object for someone connected to a particular pin.
        /// </summary>
        /// <param name="pin"></param>
        /// <returns></returns>
        public override ROOTObjectSpec[] GetConnectedPinDataAsROOTObject(PinDefinition pin)
        {
            return _parent.GetConnectedPinDataAsROOTObject(pin);
        }

        /// <summary>
        /// Called when all output pins need to be looked at by folks down-stream.
        /// </summary>
        public override void OutputPinsChanged()
        {
            _parent.OutputPinsChanged();
        }

        /// <summary>
        /// Gets the list of names that these pins call themselves by. For UI display.
        /// </summary>
        /// <param name="pin"></param>
        /// <returns></returns>
        public override string[] GetNamesOfConnectedPins(PinDefinition pin)
        {
            return _parent.GetNamesOfConnectedPins(pin);
        }
    }
}
